package club.caihappy.controller;

import club.caihappy.domain.ResponseResult;
import club.caihappy.domain.entity.Article;
import club.caihappy.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by DELL on 2022/10/24
 **/
@RestController
@RequestMapping("article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;


//    @RequestMapping("list")
//    public List<Article> test(){
//        return articleService.list();
//    }

    @GetMapping("hotArticleList")
    public ResponseResult hotArticleList() {
        return articleService.hotArticleList();
    }


    @GetMapping("articleList")
    public ResponseResult articleList(Integer pageNum, Integer pageSize, Long categoryId) {
        return articleService.articleList(pageNum, pageSize, categoryId);
    }

    @GetMapping("{id}")
    public ResponseResult getArticleDetail(@PathVariable("id") Long id) {
        return articleService.getArticleDetail(id);
    }
}
